package com.hdax.dm.scheduler.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hdax.dm.entity.scheduler.SchedulerSeat;
import com.hdax.dm.entity.scheduler.SchedulerSeatPrice;
import com.hdax.dm.scheduler.dto.PriceDto;
import com.hdax.dm.scheduler.mappers.SchedulerSeatPriceMapper;
import com.hdax.dm.scheduler.mapstruct.PriceDtoMapper;
import com.hdax.dm.scheduler.service.SchedulerSeatPriceService;
import com.hdax.dm.utils.CommonResponse;
import com.hdax.dm.utils.ResponseUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class SchedulerSeatPriceServiceImpl extends ServiceImpl<SchedulerSeatPriceMapper, SchedulerSeatPrice> implements SchedulerSeatPriceService {

    @Autowired
    private PriceDtoMapper priceDtoMapper;

    public List<SchedulerSeatPrice> prices(Long scheduleId){
        QueryWrapper<SchedulerSeatPrice> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("scheduleId",scheduleId);
        List<SchedulerSeatPrice> prices = this.list(queryWrapper);
        return prices;
    }

    @Override
    public CommonResponse<List<PriceDto>> getPrice(Long scheduleId) {
        QueryWrapper<SchedulerSeatPrice> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("scheduleId",scheduleId);
        List<SchedulerSeatPrice> prices = this.list(queryWrapper);
        List<PriceDto> dtos = priceDtoMapper.toTargetList(prices);
        return ResponseUtil.returnSuccess(dtos);
    }

    @Override
    public SchedulerSeat price(Long scheduleId, Long x, Long y) {
        return baseMapper.price(scheduleId, x, y);
    }
}
